﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace MsDAL
{
    public class Sys0a60DAL
    {
        /// <summary>
        /// 生成编码规则
        /// </summary>
        /// <param name="sncode">编码规则名词</param>
        /// <param name="usercode">用户编码</param>
        /// <returns></returns>
        public string CreateSn(string sncode, string usercode)
        {
            string sql = "sp_autoSn";

            SqlParameter[] parameters = {
					new SqlParameter("@sncode",SqlDbType.NVarChar),  
					new SqlParameter("@muser", SqlDbType.NVarChar),
                    new SqlParameter("@newsn", SqlDbType.NVarChar)
					};
            parameters[0].Value = sncode;
            parameters[1].Value = usercode;
            parameters[2].Value = "";
            parameters[0].Direction = ParameterDirection.Input;
            parameters[1].Direction = ParameterDirection.Input;
            parameters[2].Direction = ParameterDirection.Output;

            DataTable dt = DBHelper.ExecuteProc(sql, parameters);

            if (null == dt || dt.Rows.Count == 0)
                return "";


            return dt.Rows[0][0].ToString();
        }
    }
}
